The present invention relates to a storage device used as an external storage device for a computer or the like. More particularly, this invention relates to a storage device which can shorten a time required for a rearrangement process of commands and can shorten a time required for access to a magnetic disk.
As an external storage device for a computer or the like, a storage device using a large-capacity magnetic disk as a recording medium is popularly used. The density of storage devices of this type is increasing year by year with the improvement in the characteristic of the magnetic disks, the magnetic heads, and the like. With such an increase in the density, it is required that access time and processing is shortened. An effective solution for this is aspired after.
FIG. 9 is a block diagram showing the configuration of a conventional storage device 10. As shown in FIG. 9, the storage device 10 is connected to a host 30 such as a computer through SCSI (small computer system interface). The storage device 10 performs a write operation, a read operation, and the like on the basis of a command (for example, write command or read command) from the host 30. The write operation here means an operation for writing data on a magnetic disk 17 (to be described later), and the write command is a command for executing this write operation. On the other hand the read operation means an operation for reading data from the magnetic disk 17, and the read command is a command for executing the read operation.
The command is described in a form widely known as CDB (command descriptor block), and includes a command code representing the type of the command and information such as an address on the magnetic disk 17 in execution of the command. A control section 11 performs analysis of a command received from the host 30 through an I/F section 12, transmission of a status to the host 30, queuing of the commands, rearrangement of commands, and the like. Queuing of the commands is an operation of adding commands sequentially issued from the host 30 to a command queue Q1 shown in FIG. 10. The command queue Q1 is stored in a buffer memory 13, and the commands are sequentially executed from the start command of the command queue Q1.
In an example shown in FIG. 10, the command queue Q1 consists of four commands, that is, Commands C1 to C4. The rearrangement of commands is a process of selecting a command to be executed next to a command under execution from the command queue Q1 and moving the selected command to the header of the command queue Q1. In this case, the command to be selected is a command with the shortest seek time explained later.
Returning back to FIG. 9, the buffer memory 13 temporarily stores the command queue Q1, data read from the magnetic disk 17, and data to be written on the magnetic disk 17. A command execution section 14 sequentially executes the command from the start in command queue Q1 command to perform control for reading data from the magnetic disk 17 or writing data on the magnetic disk 17. A read/write section 15 comprises a modulation circuit (not shown) for modulating data to be written on the magnetic disk 17, a parallel/serial conversion circuit for converting parallel data into serial data, a demodulation circuit (not shown) for demodulating data read from the magnetic disk 17, and the like.
A head 16 is arranged to be close to the magnetic disk 17, which writes data on and reads data from the magnetic disk 17. More specifically, the head 16 writes data on the magnetic disk 17 using a magnetic field generated by a recording current supplied to a coil (not shown) in the write operation, and magnetically detects, as a reproduced voltage, the data recorded on the magnetic disk 17. The head 16 is moved along the recording surface of the magnetic disk 17 by a voice coil motor (xe2x80x9cVCMxe2x80x9d) 18.
The magnetic disk 17 is a disk-like recording medium on which data is magnetically recorded, and is rotationally driven at a high speed by an spindle motor (xe2x80x9cSPMxe2x80x9d) 19. A servo section 20 controls drive currents supplied to the VCM 18 and the SPM 19 to perform positioning control of the head 16 with respect to the magnetic disk 17.
An operation of the conventional storage device 10 will be explained below with reference to FIGS. 10, 11, and 12. The rearrangement process of commands will be explained first. When commands are sequentially transmitted from the host 30 shown in FIG. 9, these commands are sequentially input to the control section 11 through the I/F section 12. The control section 11 then analyses the commands and queues the commands into a command queue in the buffer memory 13 in the input order. The command execution section 14 executes the start command of the command queue.
In this case, a command C0 shown in FIG. 12 is executed by the command execution section 14, and the command queue Q1 shown in FIG. 10 is stored in the buffer memory 13. More specifically, as shown in FIG. 12, it is assumed that the head 16 is on a track TR1 of the magnetic disk 17 and that data is read from a sector of, for example, the track TR1 depending on the command C0. The command queue Q1 shown in FIG. 10 consists of the command C1 to C4.
As described above, in execution of the command C0, the control section 11 shown in FIG. 9 executes the rearrangement process of commands according to the flowchart shown in FIG. 11. More specifically, in step SA1 shown in FIG. 11, the control section 11 initializes the command C, at the start of the command queue Q1 (see FIG. 10) as an optimum solution command and initializes the next command C2 as a compared command. The control section 11 then proceeds to step SA2. In this case, the optimum solution command is a command executed next to the command C0 under execution. The optimum solution command is a command in which a seek time of the head 16 after the execution of the command C0 is the shortest in the command queue Q1.
The command to be initialized as the optimum solution command is a command which can be rearranged in the command queue Q1, for example, read command, or write command. When the start command of the command queue Q1 is a command which cannot be rearranged, a command which is queued below the start command and closest to the start command is initialized as the optimum solution command.
In step SA2, the control section 11 determines whether or not a compared command (=command C2) is a command that can be rearranged (a read command, a write command, or the like) If the result of determination in step SA2 is xe2x80x9cYesxe2x80x9d, then the control section 11 proceeds to step SA3. If the result of determination in step SA2 is xe2x80x9cNoxe2x80x9d, then the control section 11 proceeds to step SA7.
In step SA3, the control section 11 calculates the physical address of an optimum solution command (=command C1) and the physical address of a compared command (=command C2), and then proceeds to step SA4. The physical address of the optimum solution command is a position of the head 16 on the magnetic disk 17 shown in FIG. 12 when execution of the optimum solution command is started. Similarly, the compared command is a position of the head 16 on the magnetic disk 17 when execution of the compared command is started.
The control section 11 calculates a first seek time T1 of the optimum solution command and a second seek time T2 of the compared command in step SA4, and then proceeds to step SA5. The first seek time T1 is a time from when execution of a command under execution (in this case, the command C0) is finished to the time when execution of the optimum solution command (in this case, the command C1) is started. In other words, the first seek time T1 is a time required for movement of the head 16 from a point a at which the head 16 is located when the command C0 under execution shown in FIG. 12 is finished to a point where execution of the optimum solution command is started.
Similarly, the second seek time T2 is a time from when execution of the command under execution (in this case, the command C0) is finished to the time when execution of the compared command (in this case, the command C2) is started. In other words, the second seek time T2 is a time required for movement of the head 16 from the point a at which the head 16 is located when the command C0 under execution shown in FIG. 12 is finished to a point where execution of the compared command is started.
In step SA5, the control section 11 determines whether or not the second seek time T2 is shorter than the first seek time T1. If the result of determination in step SA5 is xe2x80x9cNoxe2x80x9d, then the control section 11 proceeds to step SA7. If the result of determination in step SA5 is xe2x80x9cYesxe2x80x9d, then the control section 11 proceeds to step SA6. The control section 11 registers the compared command as an optimum solution command in step SA6, then the control section 11 proceeds to step SA7.
In step SA7, the control section 11 determines whether or not a comparing operation performed such that a final command (in this case, the command C4) in the command queue Q1 (see FIG. 10) is used as a compared command is finished. In this case, the control section 11 determines the result as xe2x80x9cNoxe2x80x9d, and then proceeds to step SA8. The control section 11 considers the next command C3 in the command queue Q1 (see FIG. 10) as a compared command in step SA8, and then proceeds to step SA2.
Thereafter, in step SA2 and subsequent steps, as in the same operations as explained above, the process which uses the commands C2, C3 as compared commands is executed. When the command C4 (final command) shown in FIG. 10 is used as a compared command in step SA8, the control section 11 determines in step SA2 whether or not the compared command (=command C4) is a command that can be rearranged (a read command, a write command, or the like). In this case, assuming that the result of determination in step SA2 is xe2x80x9cYesxe2x80x9d, the control section 11 proceeds to step SA3.
The control section 11 calculates the physical address of an optimum solution command (for example, command C1) and the physical address of a compared command (=command C4) in step SA3, and then the control section 11 proceeds to step SA4. The control section 11 calculates the first seek time T1 of the optimum command (=command C1) and the second seek time T1 of the compared command (=command C4) in step SA4, and then the control section 11 proceeds to step SA5.
In step SA5, the control section 11 determines whether or not the second seek time T2 is shorter than the first seek time T1. In this case, the result of determination is assumed as xe2x80x9cYesxe2x80x9d, the control section 11 proceeds to step SA6. The control section 11 registers the compared command (=command C4) as an optimum solution command in step SA6, and then the control section 11 proceeds to step SA7.
In step SA7, the control section 11 determines whether or not a comparing operation performed such that a final command (in this case, the command C4) in the command queue Q1 (see FIG. 10) is used as a compared command is finished. In this case, the control section 11 determines the result as xe2x80x9cYesxe2x80x9d, and then proceeds to step SA9. In step SA9, the control section 11, as shown in FIG. 10, moves the optimum solution command (=commands C4) from the present position to the start position in the command queue Q1.
When the execution of the command C0 under execution is finished as shown in FIG. 12, the command execution section 14 executes the start commands C4 (=optimum solution command) of the command queue Q1 shown in FIG. 10 in step SA10. At this time, it is assumed that the head 16 is located at a point a on the track TR1. The servo section 20 controls the VCM 18 under the control of the command execution section 14 to move the head 16 shown in FIG. 12 in a Y direction.
In this manner, the head 16 is moved from the track TR1 to a track TR3. This track TR3 is a track on which the command C4 (optimum solution command) is executed. Since the magnetic disk 17 moves in an X direction while the head 16 moves, the head 16 moves to draw a locus S1 extending from the point a to a point b. When the head 16 is located at the point b, the movement of the head 16 is stopped, the head 16 waits for rotation of the magnetic disk 17. When the head 16 is located at a point c, the command C4 is executed.
As described above, in the conventional storage device, comparing operations for determining the optimum solution commands of all the commands C1 to C4 constituting the command queue Q1 shown in FIG. 10 is performed. However, in the conventional storage device, as the number of commands constituting a command queue increases, the number of times of the comparing operations increases accordingly. Therefore, a longer time is required to calculate optimum solution commands and to finish rearrangement of the commands.
For example, in a command queue Q2 consisting of seven commands C1 to C7 shown in FIG. 10 and having an optimum solution command (in this case, a commands C4) located at the end of the command queue Q2, the head 16 shown in FIG. 12 exceeds an seek region A within a predetermined time until the optimum solution command (=command C4) is determined, and overhead in which the magnetic disk 17 rotates once (or rotates twice or more) occurs. In this case, the seek region A within a predetermined time is a region in which the head 16 is located when the head 16 moves for a predetermined time. More specifically, in the conventional storage device, comparing operations for determining optimum solution commands of all the commands constituting a command queue. Therefore, as the number of commands increases, the time required for a rearrangement process of the commands becomes longer. In addition, when overhead occurs, a time required for access to the magnetic disk 17 is disadvantageously long.
Further, in the conventional storage device, a command queue is stored in the buffer memory 13 having a relatively low access speed, and the commands are rearranged by accessing the buffer memory 13. Thus, as the number of commands constituting the command queue increases, a total of access times becomes long. Therefore, a long time is required for a rearrangement process of the commands.
The present invention has been made in light of the problems described. It is an object of the present invention to provide a storage device which can shorten a time for a rearrangement process of commands and which can shorten a time for requiring access to a magnetic disk.
According to a first aspect of the present invention, when a command is executed, a searching unit searches a command to be executed next from a command queue according to a predetermined condition. When the searching unit finds a command in which the time depending on the relative movement distance between a head and a recording medium is not longer than a predetermined time, a rearrangement unit rearranges the command queue such that this command is preferentially executed.
Thus, even if all the commands in the command queue are not searched, when a command satisfying the predetermined condition is found, the commands are rearranged such that the command is preferentially executed. Therefore, a time required for a rearrangement process of commands can be made shorter than that in a conventional device in which all commands in a command queue are subjected to searching.
Further, since the commands are repeatedly rearranged when the searching time is left when the command is searched by the searching unit, searching precision can be improved.
According to a second aspect of the invention, when a command is executed, a searching unit searches a command to be executed next from a command queue according to a predetermined condition. When the searching unit finds a special command in the command queue, a rearrangement unit rearranges the command queue such that this special command is preferentially executed.
Since rearrangement of the commands is performed such that the special command which can immediately return a status response to the host is executed in preference to the other commands, the number of commands in the command queue can be quickly reduced. Therefore, a time required for rearrangement of the commands to be executed later can be shortened.
According to a third aspect of the present invention, commands are separated into a first command information and a second command information, and the second command information required for a rearrangement process is stored in a second memory which can be accessed at a high speed to access the second memory, so that the execution orders of the commands are rearranged. Therefore, since a time required for access to the second memory can be made shorter than that in a conventional storage device, a time required for a rearrangement process of the commands can be shortened.